package cn.ex.ymcc.web.controller;

import cn.ex.ymcc.result.JSONResult;
import cn.ex.ymcc.service.IVerifyCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @Author: ZeWangmu
 * @Date: 2022/06/15/7:26
 * @Description:
 * 生成图形验证码的接口
 */

@RestController
@RequestMapping("/verifycode")
public class VerifyCodeController {
    @Autowired
    private IVerifyCodeService verifyCodeService;

    /**
     * 1.图形验证码
     * @param key
     * @return
     */
    @GetMapping("/imageCode/{imageCodeKey}")
    public JSONResult imageCode(@PathVariable("imageCodeKey") String key){
        String codeStr = verifyCodeService.imageCode(key);
        return JSONResult.success(codeStr);

    }

    /**
     * 短信验证码
     * @param
     * @return
     */
    @GetMapping("/sendSmsCode/{mobile}")
    public JSONResult smsCode(@PathVariable("mobile") String mobile){
        verifyCodeService.getSmsCode(mobile);
        return JSONResult.success();
    }
}
